/**
 * Octopus, an XMMS2 client.
 * Copyright (C) 2014 Octopus Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

namespace Octopus {
	public class Track : Object {
		//properties need to be underscore_case (lower case only), else bindings for js don't work
		public string album         { get; private set; }
		public string artist        { get; private set; }
		public int    duration      { get; private set; }
		public string genre         { get; private set; }
		public int    id            { get; private set; }
		public string picture_front { get; private set; } //notify::picture-front
		public string title         { get; private set; }
		public int    tracknr       { get; private set; }
		public string url           { get; private set; }

		public Track () {
			Object ();
		}

		public void set_values (Xmms.Value val) {
			unowned string album;
			unowned string artist;
			unowned string genre;
			int id;
			unowned string picture_front;
			unowned string title;
			int tracknr;
			unowned string url;

			val.dict_entry_get_string("album", out album);
			this.album = album;
			val.dict_entry_get_string("artist", out artist);
			this.artist = artist;
			val.dict_entry_get_int("duration", out _duration);
			val.dict_entry_get_string("genre", out genre);
			this.genre = genre;
			val.dict_entry_get_int("id", out id);
			this.id = id;
			val.dict_entry_get_string("picture_front", out picture_front);
			this.picture_front = picture_front;
			val.dict_entry_get_string("title", out title);
			this.title = title;
			val.dict_entry_get_int("tracknr", out tracknr);
			this.tracknr = tracknr;
			val.dict_entry_get_string("url", out url);
			this.url = url;
		}
	}
}
